package pers.xx.sbm.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import pers.xx.sbm.service.ReportDataCountyService;
import pers.xx.sbm.vo.RoleSampleVo;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author ：xiexing
 * @description：区县报告数据控制器
 * @date ：2021/12/10 17:36
 */
@Controller
@RequestMapping("/reportDataCounty")
public class ReportDataCountyController {

    @Autowired
    private ReportDataCountyService reportDataCountyService;

    /**
     * 区县接口
     *
     * @return
     */
    @RequestMapping(value = "/getData", method = RequestMethod.GET)
    @ResponseBody
    public Map<String, Object> getData(String areaName, String sysCode) {
        Map result = new HashMap<>();
        List<RoleSampleVo> roleSampleVos = reportDataCountyService.getRoleSampleCount(sysCode);
        int sampleSum = 0;
        if (roleSampleVos != null && roleSampleVos.size() > 0) {
            RoleSampleVo roleSampleVo = roleSampleVos.get(roleSampleVos.size() - 1);
            sampleSum = roleSampleVo.getAllNum();
        }
        result.put("sampleSum", sampleSum);
        result.put("roleSampleVos", roleSampleVos);
        //总体调查结果

        //综合满意情况
        String totalSatisfaction = reportDataCountyService.queryTotalSatisfactionByArea(areaName);
        result.put("totalSatisfaction", totalSatisfaction);

        //区县历史满意率
        Map<String, List<Double>> areaHistoryList = reportDataCountyService.areaHistoryList(areaName);
        result.put("areaHistoryList", areaHistoryList);

        //分学段满意情况
        String xdTotalSatisfaction = reportDataCountyService.queryXdTotalSatisfactionByArea(areaName);
        result.put("xdTotalSatisfaction", xdTotalSatisfaction);
        Map<String, List<Double>> xdTotalSatisfactionRate = reportDataCountyService.queryXdTotalSatisfactionRateByArea(areaName);
        result.put("xdTotalSatisfactionRate",xdTotalSatisfactionRate);

        //分人群满意情况(学生)
        String studentTotalSatisfaction = reportDataCountyService.queryRoleTotalSatisfactionByAreaAndRole(areaName,"学生");
        result.put("studentTotalSatisfaction", studentTotalSatisfaction);
        Map<String, List<Double>> studentTotalSatisfactionRate = reportDataCountyService.queryRoleTotalSatisfactionHistoryByAreaAndRole(areaName,"学生");
        result.put("studentTotalSatisfactionRate",studentTotalSatisfactionRate);


        //分人群满意情况(教师)
        String teacherTotalSatisfaction = reportDataCountyService.queryRoleTotalSatisfactionByAreaAndRole(areaName,"教师");
        result.put("teacherTotalSatisfaction", teacherTotalSatisfaction);
        Map<String, List<Double>> teacherTotalSatisfactionRate = reportDataCountyService.queryRoleTotalSatisfactionHistoryByAreaAndRole(areaName,"教师");
        result.put("teacherTotalSatisfactionRate",teacherTotalSatisfactionRate);

        //分人群满意情况(家长)
        String parentTotalSatisfaction = reportDataCountyService.queryRoleTotalSatisfactionByAreaAndRole(areaName,"家长");
        result.put("parentTotalSatisfaction", parentTotalSatisfaction);
        Map<String, List<Double>> parentTotalSatisfactionRate = reportDataCountyService.queryRoleTotalSatisfactionHistoryByAreaAndRole(areaName,"家长");
        result.put("parentTotalSatisfactionRate",parentTotalSatisfactionRate);

        //分人群满意情况(园长)
        String yzTotalSatisfaction = reportDataCountyService.queryRoleTotalSatisfactionByAreaAndRole(areaName,"园长");
        result.put("yzTotalSatisfaction", yzTotalSatisfaction);
        Map<String, List<Double>> yzTotalSatisfactionRate = reportDataCountyService.queryRoleTotalSatisfactionHistoryByAreaAndRole(areaName,"园长");
        result.put("yzTotalSatisfactionRate",yzTotalSatisfactionRate);

        //分人群满意情况(人大代表/政协委员)
        String rddbTotalSatisfaction = reportDataCountyService.queryRoleTotalSatisfactionByAreaAndRole(areaName,"人大代表/政协委员");
        result.put("rddbTotalSatisfaction", rddbTotalSatisfaction);
        Map<String, List<Double>> rddbTotalSatisfactionRate = reportDataCountyService.queryRoleTotalSatisfactionHistoryByAreaAndRole(areaName,"人大代表/政协委员");
        result.put("rddbTotalSatisfactionRate",rddbTotalSatisfactionRate);


        //高中
        //综合满意情况
        String gzTotalSatisfaction = reportDataCountyService.queryTotalSatisfactionByAreaAndXd(areaName,"高中");
        result.put("gzTotalSatisfaction", gzTotalSatisfaction);
        Map<String, List<Double>> gzTotalSatisfactionRate = reportDataCountyService.queryTotalSatisfactionRateByAreaAndXd(areaName,"高中");
        result.put("gzTotalSatisfactionRate",gzTotalSatisfactionRate);

        //分人群(学生)
        String gzStudentTotalSatisfaction = reportDataCountyService.queryAreaTotalSatisfactionByXdAndRole(areaName,"高中","学生");
        result.put("gzStudentTotalSatisfaction", gzStudentTotalSatisfaction);
        Map<String, List<Double>> gzStudentTotalSatisfactionRate = reportDataCountyService.queryAreaTotalSatisfactionRateByXdAndRole(areaName,"高中","学生");
        result.put("gzStudentTotalSatisfactionRate",gzStudentTotalSatisfactionRate);

        //分人群(教师)
        String gzTeacherTotalSatisfaction = reportDataCountyService.queryAreaTotalSatisfactionByXdAndRole(areaName,"高中","教师");
        result.put("gzTeacherTotalSatisfaction", gzTeacherTotalSatisfaction);
        Map<String, List<Double>> gzTeacherTotalSatisfactionRate = reportDataCountyService.queryAreaTotalSatisfactionRateByXdAndRole(areaName,"高中","教师");
        result.put("gzTeacherTotalSatisfactionRate",gzTeacherTotalSatisfactionRate);

        //分人群(家长)
        String gzParentTotalSatisfaction = reportDataCountyService.queryAreaTotalSatisfactionByXdAndRole(areaName,"高中","家长");
        result.put("gzParentTotalSatisfaction", gzParentTotalSatisfaction);
        Map<String, List<Double>> gzParentTotalSatisfactionRate = reportDataCountyService.queryAreaTotalSatisfactionRateByXdAndRole(areaName,"高中","家长");
        result.put("gzParentTotalSatisfactionRate",gzParentTotalSatisfactionRate);


        //分项目(学生)
        String gzStudentProjectIndicators = reportDataCountyService.queryProjectIndicatorsByXdAndRole(areaName, "高中", "学生");
        result.put("gzStudentProjectIndicators", gzStudentProjectIndicators);
        Map<String, Object> gzStudentProjectIndicatorsList = reportDataCountyService.queryIndexSatisfactionByXdAndRole(areaName, "高中", "学生");
        result.put("gzStudentProjectIndicatorsList", gzStudentProjectIndicatorsList);

        //分项目(教师)
        String gzTeacherProjectIndicators = reportDataCountyService.queryProjectIndicatorsByXdAndRole(areaName, "高中", "教师");
        result.put("gzTeacherProjectIndicators", gzTeacherProjectIndicators);
        Map<String, Object> gzTeacherProjectIndicatorsList = reportDataCountyService.queryIndexSatisfactionByXdAndRole(areaName, "高中", "教师");
        result.put("gzTeacherProjectIndicatorsList", gzTeacherProjectIndicatorsList);

        //分项目(家长)
        String gzParentProjectIndicators = reportDataCountyService.queryProjectIndicatorsByXdAndRole(areaName, "高中", "家长");
        result.put("gzParentProjectIndicators", gzParentProjectIndicators);
        Map<String, Object> gzParentProjectIndicatorsList = reportDataCountyService.queryIndexSatisfactionByXdAndRole(areaName, "高中", "家长");
        result.put("gzParentProjectIndicatorsList", gzParentProjectIndicatorsList);


        //初中
        //综合满意情况
        String czTotalSatisfaction = reportDataCountyService.queryTotalSatisfactionByAreaAndXd(areaName,"初中");
        result.put("czTotalSatisfaction", czTotalSatisfaction);
        Map<String, List<Double>> czTotalSatisfactionRate = reportDataCountyService.queryTotalSatisfactionRateByAreaAndXd(areaName,"初中");
        result.put("czTotalSatisfactionRate",czTotalSatisfactionRate);

        //分人群(学生)
        String czStudentTotalSatisfaction = reportDataCountyService.queryAreaTotalSatisfactionByXdAndRole(areaName,"初中","学生");
        result.put("czStudentTotalSatisfaction", czStudentTotalSatisfaction);
        Map<String, List<Double>> czStudentTotalSatisfactionRate = reportDataCountyService.queryAreaTotalSatisfactionRateByXdAndRole(areaName,"初中","学生");
        result.put("czStudentTotalSatisfactionRate",czStudentTotalSatisfactionRate);

        //分人群(教师)
        String czTeacherTotalSatisfaction = reportDataCountyService.queryAreaTotalSatisfactionByXdAndRole(areaName,"初中","教师");
        result.put("czTeacherTotalSatisfaction", czTeacherTotalSatisfaction);
        Map<String, List<Double>> czTeacherTotalSatisfactionRate = reportDataCountyService.queryAreaTotalSatisfactionRateByXdAndRole(areaName,"初中","教师");
        result.put("czTeacherTotalSatisfactionRate",czTeacherTotalSatisfactionRate);

        //分人群(家长)
        String czParentTotalSatisfaction = reportDataCountyService.queryAreaTotalSatisfactionByXdAndRole(areaName,"初中","家长");
        result.put("czParentTotalSatisfaction", czParentTotalSatisfaction);
        Map<String, List<Double>> czParentTotalSatisfactionRate = reportDataCountyService.queryAreaTotalSatisfactionRateByXdAndRole(areaName,"初中","家长");
        result.put("czParentTotalSatisfactionRate",czParentTotalSatisfactionRate);


        //分项目(学生)
        String czStudentProjectIndicators = reportDataCountyService.queryProjectIndicatorsByXdAndRole(areaName, "初中", "学生");
        result.put("czStudentProjectIndicators", czStudentProjectIndicators);
        Map<String, Object> czStudentProjectIndicatorsList = reportDataCountyService.queryIndexSatisfactionByXdAndRole(areaName, "初中", "学生");
        result.put("czStudentProjectIndicatorsList", czStudentProjectIndicatorsList);

        //分项目(教师)
        String czTeacherProjectIndicators = reportDataCountyService.queryProjectIndicatorsByXdAndRole(areaName, "初中", "教师");
        result.put("czTeacherProjectIndicators", czTeacherProjectIndicators);
        Map<String, Object> czTeacherProjectIndicatorsList = reportDataCountyService.queryIndexSatisfactionByXdAndRole(areaName, "初中", "教师");
        result.put("czTeacherProjectIndicatorsList", czTeacherProjectIndicatorsList);

        //分项目(家长)
        String czParentProjectIndicators = reportDataCountyService.queryProjectIndicatorsByXdAndRole(areaName, "初中", "家长");
        result.put("czParentProjectIndicators", czParentProjectIndicators);
        Map<String, Object> czParentProjectIndicatorsList = reportDataCountyService.queryIndexSatisfactionByXdAndRole(areaName, "初中", "家长");
        result.put("czParentProjectIndicatorsList", czParentProjectIndicatorsList);


        //小学
        //综合满意情况
        String xxTotalSatisfaction = reportDataCountyService.queryTotalSatisfactionByAreaAndXd(areaName,"小学");
        result.put("xxTotalSatisfaction", xxTotalSatisfaction);
        Map<String, List<Double>> xxTotalSatisfactionRate = reportDataCountyService.queryTotalSatisfactionRateByAreaAndXd(areaName,"小学");
        result.put("xxTotalSatisfactionRate",xxTotalSatisfactionRate);

        //分人群(学生)
        String xxStudentTotalSatisfaction = reportDataCountyService.queryAreaTotalSatisfactionByXdAndRole(areaName,"小学","学生");
        result.put("xxStudentTotalSatisfaction", xxStudentTotalSatisfaction);
        Map<String, List<Double>> xxStudentTotalSatisfactionRate = reportDataCountyService.queryAreaTotalSatisfactionRateByXdAndRole(areaName,"小学","学生");
        result.put("xxStudentTotalSatisfactionRate",xxStudentTotalSatisfactionRate);

        //分人群(教师)
        String xxTeacherTotalSatisfaction = reportDataCountyService.queryAreaTotalSatisfactionByXdAndRole(areaName,"小学","教师");
        result.put("xxTeacherTotalSatisfaction", xxTeacherTotalSatisfaction);
        Map<String, List<Double>> xxTeacherTotalSatisfactionRate = reportDataCountyService.queryAreaTotalSatisfactionRateByXdAndRole(areaName,"小学","教师");
        result.put("xxTeacherTotalSatisfactionRate",xxTeacherTotalSatisfactionRate);

        //分人群(家长)
        String xxParentTotalSatisfaction = reportDataCountyService.queryAreaTotalSatisfactionByXdAndRole(areaName,"小学","家长");
        result.put("xxParentTotalSatisfaction", xxParentTotalSatisfaction);
        Map<String, List<Double>> xxParentTotalSatisfactionRate = reportDataCountyService.queryAreaTotalSatisfactionRateByXdAndRole(areaName,"小学","家长");
        result.put("xxParentTotalSatisfactionRate",xxParentTotalSatisfactionRate);


        //分项目(学生)
        String xxStudentProjectIndicators = reportDataCountyService.queryProjectIndicatorsByXdAndRole(areaName, "小学", "学生");
        result.put("xxStudentProjectIndicators", xxStudentProjectIndicators);
        Map<String, Object> xxStudentProjectIndicatorsList = reportDataCountyService.queryIndexSatisfactionByXdAndRole(areaName, "小学", "学生");
        result.put("xxStudentProjectIndicatorsList", xxStudentProjectIndicatorsList);

        //分项目(教师)
        String xxTeacherProjectIndicators = reportDataCountyService.queryProjectIndicatorsByXdAndRole(areaName, "小学", "教师");
        result.put("xxTeacherProjectIndicators", xxTeacherProjectIndicators);
        Map<String, Object> xxTeacherProjectIndicatorsList = reportDataCountyService.queryIndexSatisfactionByXdAndRole(areaName, "小学", "教师");
        result.put("xxTeacherProjectIndicatorsList", xxTeacherProjectIndicatorsList);

        //分项目(家长)
        String xxParentProjectIndicators = reportDataCountyService.queryProjectIndicatorsByXdAndRole(areaName, "小学", "家长");
        result.put("xxParentProjectIndicators", xxParentProjectIndicators);
        Map<String, Object> xxParentProjectIndicatorsList = reportDataCountyService.queryIndexSatisfactionByXdAndRole(areaName, "小学", "家长");
        result.put("xxParentProjectIndicatorsList", xxParentProjectIndicatorsList);


        //幼儿园
        //综合满意情况
        String yeyTotalSatisfaction = reportDataCountyService.queryTotalSatisfactionByAreaAndXd(areaName,"幼儿园");
        result.put("yeyTotalSatisfaction", yeyTotalSatisfaction);
        Map<String, List<Double>> yeyTotalSatisfactionRate = reportDataCountyService.queryTotalSatisfactionRateByAreaAndXd(areaName,"幼儿园");
        result.put("yeyTotalSatisfactionRate",yeyTotalSatisfactionRate);

        //分人群(教师)
        String yeyTeacherTotalSatisfaction = reportDataCountyService.queryAreaTotalSatisfactionByXdAndRole(areaName,"幼儿园","教师");
        result.put("yeyTeacherTotalSatisfaction", yeyTeacherTotalSatisfaction);
        Map<String, List<Double>> yeyTeacherTotalSatisfactionRate = reportDataCountyService.queryAreaTotalSatisfactionRateByXdAndRole(areaName,"幼儿园","教师");
        result.put("yeyTeacherTotalSatisfactionRate",yeyTeacherTotalSatisfactionRate);

        //分人群(家长)
        String yeyParentTotalSatisfaction = reportDataCountyService.queryAreaTotalSatisfactionByXdAndRole(areaName,"幼儿园","家长");
        result.put("yeyParentTotalSatisfaction", yeyParentTotalSatisfaction);
        Map<String, List<Double>> yeyParentTotalSatisfactionRate = reportDataCountyService.queryAreaTotalSatisfactionRateByXdAndRole(areaName,"幼儿园","家长");
        result.put("yeyParentTotalSatisfactionRate",yeyParentTotalSatisfactionRate);

        //分人群(园长)
        String yeyYzTotalSatisfaction = reportDataCountyService.queryAreaTotalSatisfactionByXdAndRole(areaName,"幼儿园","园长");
        result.put("yeyYzTotalSatisfaction", yeyYzTotalSatisfaction);
        Map<String, List<Double>> yeyYzTotalSatisfactionRate = reportDataCountyService.queryAreaTotalSatisfactionRateByXdAndRole(areaName,"幼儿园","园长");
        result.put("yeyYzTotalSatisfactionRate",yeyYzTotalSatisfactionRate);

        //分人群(人大代表/政协委员)
        String yeyRddbTotalSatisfaction = reportDataCountyService.queryAreaTotalSatisfactionByXdAndRole(areaName,"幼儿园","人大代表/政协委员");
        result.put("yeyRddbTotalSatisfaction", yeyRddbTotalSatisfaction);
        Map<String, List<Double>> yeyRddbTotalSatisfactionRate = reportDataCountyService.queryAreaTotalSatisfactionRateByXdAndRole(areaName,"幼儿园","人大代表/政协委员");
        result.put("yeyRddbTotalSatisfactionRate",yeyRddbTotalSatisfactionRate);

        //分项目(教师)
        String yeyTeacherProjectIndicators = reportDataCountyService.queryProjectIndicatorsByXdAndRole(areaName, "幼儿园", "教师");
        result.put("yeyTeacherProjectIndicators", yeyTeacherProjectIndicators);
        Map<String, Object> yeyTeacherProjectIndicatorsList = reportDataCountyService.queryIndexSatisfactionByXdAndRole(areaName, "幼儿园", "教师");
        result.put("yeyTeacherProjectIndicatorsList", yeyTeacherProjectIndicatorsList);

        //分项目(家长)
        String yeyParentProjectIndicators = reportDataCountyService.queryProjectIndicatorsByXdAndRole(areaName, "幼儿园", "家长");
        result.put("yeyParentProjectIndicators", yeyParentProjectIndicators);
        Map<String, Object> yeyParentProjectIndicatorsList = reportDataCountyService.queryIndexSatisfactionByXdAndRole(areaName, "幼儿园", "家长");
        result.put("yeyParentProjectIndicatorsList", yeyParentProjectIndicatorsList);

        //分项目(园长)
        String yeyYzProjectIndicators = reportDataCountyService.queryProjectIndicatorsByXdAndRole(areaName, "幼儿园", "园长");
        result.put("yeyYzProjectIndicators", yeyYzProjectIndicators);
        Map<String, Object> yeyYzProjectIndicatorsList = reportDataCountyService.queryIndexSatisfactionByXdAndRole(areaName, "幼儿园", "园长");
        result.put("yeyYzProjectIndicatorsList", yeyYzProjectIndicatorsList);

        //分项目(人大代表/政协委员)
        String yeyRddbProjectIndicators = reportDataCountyService.queryProjectIndicatorsByXdAndRole(areaName, "幼儿园", "人大代表/政协委员");
        result.put("yeyRddbProjectIndicators", yeyRddbProjectIndicators);
        Map<String, Object> yeyRddbProjectIndicatorsList = reportDataCountyService.queryIndexSatisfactionByXdAndRole(areaName, "幼儿园", "人大代表/政协委员");
        result.put("yeyRddbProjectIndicatorsList", yeyRddbProjectIndicatorsList);

        return result;
    }
}
